<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:p="http://primefaces.org/ui"
	xmlns:ui="http://java.sun.com/jsf/facelets">


<body>
	<ui:composition template="/template2.xhtml">
		<ui:define name="titulo">Listar Vaga</ui:define>
		<ui:define name="barra_titulo">Listar Vagas</ui:define>
		<ui:define name="corpo">

			<p:messages>
			</p:messages>

			<h:form id="formListar">
				<p:dataTable var="vaga" value="#{vagaBean.vagas}"
					selection="#{vagaBean.vaga }" update="display"
					selectionMode="single" emptyMessage="Vagas não Cadastrados"
					rowKey="#{vaga.id}">

					<p:ajax event="rowSelect" update=":formAlterar:infoAlt"
						oncomplete="dialogo.show()" />

					<p:column>
						<f:facet name="header">
							<h:outputText value="Id:" />
						</f:facet>
						<h:outputText value="#{vaga.id}" />
					</p:column>
					<p:column>
						<f:facet name="header">
							<h:outputText value="Setor:" />
						</f:facet>
						<h:outputText value="#{vaga.setor}" />
					</p:column>
					<p:column>
						<p:commandLink type="button" oncomplete="cd.show()" update=":dlg">
							<h:graphicImage alt="Excluir Registro" library="imagens"
								name="delete.png" styleClass="image"></h:graphicImage>
							<f:setPropertyActionListener target="#{vagaBean.vaga}"
								value="#{vaga}" />
						</p:commandLink>
					</p:column>
				</p:dataTable>
			</h:form>

			<h:form id="dlg">
				<p:confirmDialog
					message="Deseja realmente excluir o vaga: #{vagaBean.vaga.id}?"
					hideEffect="explode" header="Excluir" severity="alert"
					widgetVar="cd">
					<p:commandButton value="Sim" actionListener="#{vagaBean.excluir}"
						update=":formListar" oncomplete="cd.hide()" />
					<p:commandButton value="Não" onclick="cd.hide()" type="button" />
				</p:confirmDialog>
			</h:form>

			<p:dialog header="Editar Vaga" widgetVar="dialogo" width="400"
				modal="true" resizable="false" closable="false">
				<p:outputPanel id="display">
					<h:form id="formAlterar">
						<h:panelGrid columns="2" id="infoAlt">
							<h:outputLabel value="Setor" />
							<p:inputText value="#{vagaBean.vaga.setor}" />
						</h:panelGrid>
						<br />
						<p:commandButton action="#{vagaBean.editar}" value="Salvar"
							update=":formListar" oncomplete="dialogo.hide()" />
						<p:commandButton value="Cancelar"
							action="#{vagaBean.cancelaEditar}" oncomplete="dialogo.hide()" />
					</h:form>
				</p:outputPanel>
			</p:dialog>

		</ui:define>
	</ui:composition>
</body>
</html>
